<?php

class FormElement_Boolean extends FormElement
{

  public $trueLabel = 'Yes';

  public $falseLabel = 'No';

  public $trueValue = 1;

  public $falseValue = 0;

  public function render($row, $action)
  {
    switch ($action) {
      case Form::ACTION_EDIT :
      case Form::ACTION_CREATE :
        $this->set('trueLabel', $this->trueLabel);
        $this->set('falseLabel', $this->falseLabel);
        $this->set('trueValue', $this->trueValue);
        $this->set('falseValue', $this->falseValue);

        break;
    }

    return parent::render($row, $action);
  }

  public function getDisplayValue(&$row)
  {
    return $this->getValue($row) == $this->trueValue ? $this->trueLabel : $this->falseLabel;
  }

}

?>